package com.xbongbong.saas.service;

import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.DepartmentVO;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.pro.listbatch.pojo.dto.AddLabelDTO;
import com.xbongbong.pro.warehouse.pojo.dto.ProductWarehouseMapDTO;
import com.xbongbong.pro.warehouse.pojo.dto.WareHouseEditAttrUpdateDTO;
import com.xbongbong.pro.warehouse.pojo.dto.WarehouseDeleteBatchDTO;
import com.xbongbong.pro.warehouse.pojo.dto.WarehouseIdListDTO;
import com.xbongbong.pro.warehouse.pojo.dto.WarehouseListDTO;
import com.xbongbong.pro.warehouse.pojo.dto.WarehouseUpdateByBusinessRuleDTO;
import com.xbongbong.pro.warehouse.pojo.vo.ProductWarehouseMapVO;
import com.xbongbong.pro.warehouse.pojo.vo.WarehouseDeleteBatchVO;
import com.xbongbong.pro.warehouse.pojo.vo.WarehouseIdListVO;
import com.xbongbong.pro.warehouse.pojo.vo.WarehouseListVO;
import com.xbongbong.saas.domain.entity.WarehouseUserEntity;

import java.util.List;
import java.util.Set;

/**
 * 仓库业务处理
 *
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/22
 * @since v1.0
 */
public interface WarehouseService {
    /**
     * 仓库保存前saas特殊校验
     *
     * @param validateDataDTO saas特殊校验数据入参
     * @throws XbbException 业务异常
     * @author feng.zheng
     * @date 2019/1/18
     */
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * 仓库保存后逻辑
     *
     * @param saasFormSaveDTO saas保存数据
     * @throws XbbException 业务异常
     * @author feng.zheng
     */
    void afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;



    /**
     * 获取某用户主负责的仓库
     *
     * @param warehouseListDTO
     * @return 如果用户为管理员，则获取全公司的仓库；否则获取自己主负责的仓库
     * @author lcx
     * @date 2019/2/18 12:08
     * @since v1.0
     */
    WarehouseListVO getManagetWarehouses(WarehouseListDTO warehouseListDTO);

    /**
     * 选择产品时返回仓库数据
     *
     * @param productWarehouseMapDTO 是否获取所有的仓库，1：是；0：否
     * @return Map<String, JSONArray>, 里面有两个键值对，key为allWarehouseArray，则值是所有的仓库，如果allWarehouse值为0，则该数组size=0；
     *                                                 key为userWarehouseArray，则值是用户负责的仓库
     * @author lcx
     * @date 2019/2/18 12:08
     * @since v1.0
     */
    ProductWarehouseMapVO getSelectProductWarehouses(ProductWarehouseMapDTO productWarehouseMapDTO) throws XbbException;

    /**
     * 筛选仓库
     *
     * @param warehouseIdListDTO
     * @return 如果传入了仓库，则筛选此仓库，否则筛选全公司或下属和自己的仓库
     * @author 周智
     * 创建时间 2017-12-15 11:09
     */
    WarehouseIdListVO getWarehouseIds(WarehouseIdListDTO warehouseIdListDTO);

    /**
     * 删除仓库
     * @param warehouseDeleteBatchDTO
     * @return
     * @throws XbbException
     */
    WarehouseDeleteBatchVO deleteBatch(WarehouseDeleteBatchDTO warehouseDeleteBatchDTO) throws XbbException;

    /**
     * 根据权限获取仓库
     * @param loginUser
     */
    List<Long> getWarehouseIdsByPermission(UserVO loginUser, Set<DepartmentVO> depSet) throws XbbException;

    /**
     * 根据业务规则，更新仓库
     * @author 吴峰
     * @date 2019/8/19 16:42
     * @param warehouseUpdateByBusinessRuleDTO
     * @return void
     * @throws XbbException 业务异常
     */
    void updateBatchByBusinessRule(WarehouseUpdateByBusinessRuleDTO warehouseUpdateByBusinessRuleDTO) throws XbbException;

    /**
     * 获取用户负责的仓库用户的关联实体
     * @param user
     * @return
     */
    List<WarehouseUserEntity> getWarehouseManagerList(UserVO user);

    List<PaasFormDataEntityExt> getWarehouseByPermission(UserVO loginUser, Set<DepartmentVO> depSet) throws XbbException;

    void updateBatchLabelAttr(AddLabelDTO addLabelDTO, List<PaasFormDataEntityExt> addBatchList, Boolean addOrDelete) throws XbbException;

    void batchEditAttr(WareHouseEditAttrUpdateDTO wareHouseEditAttrUpdateDTO) throws XbbException;

    void afterSaveForWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    void afterSaveForUpdateWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    void updateProductLinkWarehouseName(String corpid, Long dataId, String warehouseName) throws XbbException;
}
